package edu.jmu.springmvc;

import org.junit.Test;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import junit.framework.Assert;

public class TestFormat {

	@Test
	public void test() {
		
		
		
		RestTemplate restTemplate = new RestTemplate();
		MultiValueMap<String, String> form = new LinkedMultiValueMap<String,String>();
		/*form.add("Accept", "text/html");
		form.add("Content-Type", "text/html");*/
		form.add("userName", "tom");
		form.add("password", "123456");
		form.add("age", "45");
		form.add("birthday", "1980-01-01");
		form.add("salary","4,500.00");
		String url = "http://localhost:8080/springstudy/user/handle82";
		
		/*HttpHeaders requestHeaders = new HttpHeaders();
		requestHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
		HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(form, requestHeaders);
		ResponseEntity<User> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, User.class);
		User result = response.getBody();*/
		//System.out.println("TestFormat.test():"+result);
		String html = restTemplate.postForObject(url, form, String.class);
		System.out.println("TestFormat.test():"+html);
		Assert.assertNotNull(html);
		Assert.assertTrue(html.indexOf("tom")>-1);
		
		
	}

}
